﻿using BCL.BaseLib.Basics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using BCL.Tool;
namespace BCL.WPFComponent
{
    /// <summary>
    /// UCMuneItem.xaml 的交互逻辑
    /// </summary>
    public partial class UCMuneItem : UserControl
    {
        public UCMuneItem()
        {
            InitializeComponent();
        }
        public UCMuneItem(BCL.BaseLib.FunctionEntity fe)
        {
            InitializeComponent();
            if (fe==null || fe.ItemType != BaseLib.FunctionItemType.Group)
                return;
            textGroup.Text = fe.Title.Language();
            foreach (var item in fe.Items)
            {
                string path1 = item.ImagePath.Insert(item.ImagePath.LastIndexOf("."), "_2");
                Image image=  new Image { Source = new BitmapImage(new Uri(AppDomain.CurrentDomain.BaseDirectory + "\\" + path1)), Height=16,Width=16};
                TextBlock tb = new TextBlock { Margin=new Thickness(3,0,0,0), Text=item.Title?.Language(),FontSize=14, Foreground=new SolidColorBrush(Color.FromArgb(255,0x33,0x33,0x33)) };
                image.MouseDown+= (send, e) => BCLApplication.MainForm.OpenFunction(item);
                tb.MouseDown += (send, e) => BCLApplication.MainForm.OpenFunction(item);
                if (StackPanelMain.Children.Count != 0)
                    image.Margin = new Thickness(20,0,0,0);
                this.StackPanelMain.Children.Add(image);
                this.StackPanelMain.Children.Add(tb);

            }
        }
    }
}
